package site.addzero.cli.autoinit.common

import graavlvm_download.SoftCenter
import org.koin.core.annotation.Single
import site.addzero.cli.setting.SettingContext.USEFUL_SOFT_DIR
import site.addzero.task.InitTask
import java.io.File

@Single
class AutoInitGraavlvm : InitTask {
    override val support: Boolean = true

    /**
     * 执行 GraalVM 初始化任务
     */
    override suspend fun asynctask(): Boolean {
        val file = File(USEFUL_SOFT_DIR, "graalvm-jdk.zip")
        if (file.exists()) {
            println("GraalVM 已存在，跳过下载")
            return true
        }
        
        val destinationPath = file.absolutePath
        SoftCenter.downloadGraalvm(destinationPath = destinationPath)
        return true
    }
}
